import { AnimationClip, AnimationComponent } from 'cc'
import { StateMachine } from '../../Base/StateMachine'
import { State } from '../../Base/AnimationState'

export enum SMOKE_STATE {
  IDLE_TOP = 'idle_top', //待机-上
  IDLE_BOTTOM = 'idle_bottom', //待机-下
  IDLE_LEFT = 'idle_left', //待机-左
  IDLE_RIGHT = 'idle_right', //待机-右
}

export class SmokeStateMachine extends StateMachine<SMOKE_STATE> {
  constructor(private _animationComponent: AnimationComponent) {
    super()
    this.initStateMap()
  }
  initStateMap() {
    const speed = 1 / 8
    const acp = this._animationComponent
    const idleBaseUrl = 'texture/smoke/idle'
    this.addState(SMOKE_STATE.IDLE_TOP, new State(acp, `${idleBaseUrl}/top`, speed, AnimationClip.WrapMode.Loop))
    this.addState(SMOKE_STATE.IDLE_BOTTOM, new State(acp, `${idleBaseUrl}/bottom`))
    this.addState(SMOKE_STATE.IDLE_LEFT, new State(acp, `${idleBaseUrl}/left`))
    this.addState(SMOKE_STATE.IDLE_RIGHT, new State(acp, `${idleBaseUrl}/right`))
  }
}
